// TestHttpDlg.h : header file
#include "WHHttpConnection.h"

#pragma once
#define MAX_PARAM_COUNT		5

struct ParamRange
{
	int nMin;
	int nMax;
	int nCur;
};

// CTestHttpDlg dialog
class CTestHttpDlg
	: public CDialog
	, public IWHHttpConnEvent
{
// Construction
public:
	CTestHttpDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TESTHTTP_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

	virtual void	OnHttpReply(CString strFile, MAP_HTTPHEADER mapReqHeader, CString strReqBody,
		CString strReplyLine, MAP_HTTPHEADER mapHeader, CString strReplyFile);
	virtual void	OnUnReachable(CWHHttpConnection* pConn);

private:
	int			GetReplyCode(CString strLine);
	void		EditAddText(CString strText);
	void		VisitUrl(CString strUrl, CString strCookie);

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedVisit();

private:
	CWHHttpConnection		m_oHttpSession;

	CEdit		m_oEdit;
	CString		m_strOutput;

	ParamRange	m_pstParamRange[MAX_PARAM_COUNT];
	int			m_nParamCount;
	CString		m_strFormatUrl;
	BOOL		m_bFinished;

	map<CString, CString>	m_mapUrlFileName;
};
